<template>
    <div>
        <MenuItem style="padding-left: 15px" :roles="role1" :route="route1" :c-router="cRouter"/>
        <MenuItem style="padding-left: 15px" :roles="role2" :route="route2" :c-router="cRouter"/>
        <MenuItem style="padding-left: 15px" :roles="role3" :route="route3" :c-router="cRouter"/>
        <MenuItem style="padding-left: 15px" :roles="role4" :route="route4" :c-router="cRouter"/>

        <ExpandMenu v-show="show" title="Reports Manage" :icon="expandIcon" :c-router="cRouter" :subMenu="sub"/>
        <MenuItem style="padding-left: 15px" :roles="role5" :route="route5" :c-router="cRouter"/>

    </div>
</template>

<script>
import MenuItem from "@/components/NPMSMenu/MenuItem";
import ExpandMenu from "@/components/NPMSMenu/ExpandMenu";

export default {
    name: "NPMSMenu",
    components: {ExpandMenu, MenuItem},
    data() {
        return {
            show:false,
            role1: [
                this.$npms.roles.MARKET_MGR,
                this.$npms.roles.ADMIN,
                this.$npms.roles.CUSTOMER_MGR,
                this.$npms.roles.MARKET_SP,
                this.$npms.roles.MARKET_SUB_MGR,
                this.$npms.roles.BUSSINESS_MGR,

            ],
            role2: [
                this.$npms.roles.ADMIN,
                this.$npms.roles.MARKET_SP,
            ],
            role3: [
                this.$npms.roles.MARKET_MGR,
                this.$npms.roles.ADMIN,
                this.$npms.roles.CUSTOMER_MGR,
                this.$npms.roles.MARKET_SP,
                this.$npms.roles.MARKET_SUB_MGR,
                this.$npms.roles.BUSSINESS_MGR,
            ],
            role4: [
                this.$npms.roles.MARKET_MGR,
                this.$npms.roles.ADMIN,
                this.$npms.roles.CUSTOMER_MGR,
                this.$npms.roles.MARKET_SUB_MGR,

            ],
            role5: [
                this.$npms.roles.MARKET_MGR,
                this.$npms.roles.ADMIN,
                this.$npms.roles.MARKET_SUB_MGR,
                this.$npms.roles.BUSSINESS_MGR,
            ],

            expandIcon: require('@/assets/icon/12.png'),
            route1: {
                title: "Customer Manage",
                icon: require('@/assets/icon/8.png'),
                router: "/npms/customer"
            },
            route2: {
                title: "Customer HandOver",
                icon: require('@/assets/icon/9.png'),
                router: "/npms/handover"
            },
            route3: {
                title: "Chance Manage",
                icon: require('@/assets/icon/10.png'),
                router: "/npms/chance"
            },
            route4: {
                title: "Sales Daily Report Fill",
                icon: require('@/assets/icon/11.png'),
                router: "/npms/report"
            },
            route5: {
                title: "Chance Approval",
                icon: require('@/assets/icon/15.png'),
                router: "/npms/approval"
            },
            sub: [
                {
                    route: {
                        title: "Search Daily Report",
                        icon: require('@/assets/icon/13.png'),
                        router: "/npms/searchReport"
                    },
                },
                {
                    route: {
                        title: "Customer Relation Report",
                        icon: require('@/assets/icon/14.png'),
                        router: "/npms/searchCusRelation"
                    },
                },
                {
                    route: {
                        title: "Handover Report",
                        icon: require('@/assets/icon/9.png'),
                        router: "/npms/searchHandover"
                    },
                },
            ]
        }
    },
    computed: {
        cRouter: function () {
            return this.$route.path
        },
    },
    mounted() {
        var roles=[
            this.$npms.roles.ADMIN,
            this.$npms.roles.MARKET_SP,
            this.$npms.roles.MARKET_MGR,
            this.$npms.roles.MARKET_SUB_MGR,
        ]
        var user = this.$store.getters.getUser;
        var role = user.roles[0]
        var find =false
        roles.find(function (value) {

            if (value === role) {
                find = true
                //则包含该元素
            }
        })
        this.show = find
    }

}
</script>

<style scoped>

</style>